package com.movie.modules.api.controller;

import com.movie.common.utils.R;
import com.movie.modules.api.service.AppService;
import com.movie.modules.jf.entity.VipEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author JF-PJJ
 */
@RestController
@RequestMapping("/api")
@Api(tags = "个人中心")
public class ApiVipController {

    @Autowired
    private AppService appService;

    @GetMapping("/movie/collect")
    @ApiOperation("收藏电影列表")
    public R movieVipList(Integer page,Integer vipId){
        return R.ok().put("data",appService.movieVipList(page,vipId));
    }

    @GetMapping("/actor/collect")
    @ApiOperation("关注演员列表")
    public R actorVipList(Integer page,Integer vipId){
        return R.ok().put("data",appService.actorVipList(page,vipId));
    }

    @GetMapping("/vip/info/{vipId}")
    @ApiOperation("用户详情")
    public R vipInfo(@PathVariable Integer vipId){
        return R.ok().put("data",appService.vipDetail(vipId));
    }

    @PostMapping("/vip/update")
    @ApiOperation("修改用户信息")
    public R vipUpdate(@RequestBody VipEntity vip){
        appService.updateVip(vip);
        return R.ok();
    }

    @GetMapping("/comment/vip")
    @ApiOperation("我的影评列表")
    public R commentListByVip(Integer page,Integer vipId){
        return R.ok().put("data",appService.commentList(page,vipId));
    }

    @DeleteMapping("/comment/delete/{commentId}")
    @ApiOperation("删除评论")
    public R deleteComment(@PathVariable("commentId") Integer commentId){
        appService.deleteComment(commentId);
        return R.ok();
    }
}
